package com.serviceImpl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.bean.Stock;
import com.mapper.StockMapper;
import com.service.StockService;

/**
 * @author  author : 张鹏
 * @date createTime：2018年2月22日 下午5:54:58 
 * @Description: 该类的功能描述
 */
@Service
public class StockServiceImpl implements StockService {
	@Resource
	private StockMapper stockMapper;
	
	@Override
	public Double getStockQuantity(int materialId) {
		// TODO Auto-generated method stub
		return stockMapper.selectQuantityByMaterialId(materialId);
	}

	@Override
	public int insert(Stock stock) {
		// TODO Auto-generated method stub
		return stockMapper.insert(stock);
	}

	@Override
	public List<Stock> getInStockRecord() {
		// TODO Auto-generated method stub
		return stockMapper.selectByQuantityMoreOne();
	}

	@Override
	public List<Stock> getOutStockRecord() {
		// TODO Auto-generated method stub
		return stockMapper.selectByQuantityLessOne();
	}

	@Override
	public int inStock(Stock stock) {
		return stockMapper.updateByStateZero(stock);
	}

	@Override
	public int outStock(Stock stock) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<Stock> getStockByState(int state) {
		// TODO Auto-generated method stub
		return stockMapper.selectByState(state);
	}

	@Override
	public List<Stock> getAllStock() {
		// TODO Auto-generated method stub
		return stockMapper.selectAllStock();
	}

	@Override
	public List<Stock> getStockByMaterialIdOrMaterialName(String searchWords) {
		// TODO Auto-generated method stub
		return stockMapper.selectByMaterialIdOrMaterialName(searchWords);
	}

}
